package main

import "fmt"

func solution(n int, a []int) []int {
	// PLEASE DO NOT MODIFY THE FUNCTION SIGNATURE
	// write code here
	var l []int

	for {
		l = append(l, a[0])
		a = a[1:]
		first := a[0]
		a = append(a[1:], first)
		if len(a) == 1 {
			l = append(l, a[0])
			break
		}
	}

	return l
}

func main() {
	fmt.Println(fmt.Sprintf("%v", solution(5, []int{5, 3, 2, 1, 4})) == fmt.Sprintf("%v", []int{5, 2, 4, 1, 3}))
	fmt.Println(fmt.Sprintf("%v", solution(4, []int{4, 1, 3, 2})) == fmt.Sprintf("%v", []int{4, 3, 1, 2}))
	fmt.Println(fmt.Sprintf("%v", solution(6, []int{1, 2, 3, 4, 5, 6})) == fmt.Sprintf("%v", []int{1, 3, 5, 2, 6, 4}))
}
